/**********************************************
 * 	TestFileIO.java							  *
 *  Course: CS3343							  *
 *  Version: 2.5    Release 1				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package testFile;


import org.junit.Before;
import java.io.*;
import file.FileIO;
import junit.framework.TestCase;

public class TestFileIO extends TestCase{
    private FileIO io;
    
	@Before
	public void setUp() throws Exception {
		io = new FileIO();
		
	}
	
	public void testReadFile(){
		String result = io.getFileContents("HelloWorld.txt");
		assertEquals("Hello World! This is the test of the reading function@@", result);
	}
	public void testWriteFile(){
		String contents = "This is the new world!";
		boolean status = io.writeToFile(contents, "NewWorld.txt");
		assertEquals(status, status);
		File move = new File("output/NewWorld.txt");
		move.renameTo(new File("input/NewWorld.txt"));
	
		String result = io.getFileContents("NewWorld.txt");
		new File("input/NewWorld.txt").delete();
		move.delete();
		assertEquals(contents, result);
		
	
	}

}
